{% extends "public/base.html" %}
{% block sidebar %}
    {% include "public/sidebar_resource.html" %}
{% endblock %}


{% block css %}
    <style>
        table .gradeA .dropdown-menu{min-width: 100px;}

    #host_list{ height: 250px; overflow-y: scroll;border:1px solid #ccc; width:300px;padding-left:10px;float:left;margin-right:20px;}
    .modal-body{min-height: 280px;}
    #zabbix_group{width:200px;}

    </style>

{% endblock %}

{% block content %}

<div class="main">

    <!-- row -->
    <div class="row">

        <!-- col 12 -->
        <div class="col-md-12">
            <!-- tile -->
            <section class="tile transparent">

                <!-- tile header -->
                <div class="tile-header transparent">
                    <h1><strong>服务器列表</strong>  </h1>

                    <div class="controls">
                      <a href="#" class="refresh"><i class="fa fa-refresh"></i></a>
                      <a href="#" class="remove"><i class="fa fa-times"></i></a>
                    </div>
                </div>
                <!-- /tile header -->

                <!-- tile body -->
                <div class="tile-body color transparent-black rounded-corners">
                    <div class="table-responsive">


                        <table  class="table table-datatable table-custom table-hover" id="basicDataTable">

                            <thead>

                                <tr>
                                    <th>#</th>
                                    <th >业务线</th>
                                    <th >产品线</th>
                                    <th >主机名</th>
                                    <th >内网IP</th>
                                    <th >状态</th>
                                    <th >CPU梳数</th>
                                    <th >硬盘信息</th>
                                    <th >内存信息</th>
                                    <th >上次检测时间</th>
                                    <th >操作</th>
                                </tr>

                            </thead>

                            <tbody>

                                {% for server in server_list %}
                                    <tr class="gradeA">
                                        <td> {{ forloop.counter }} </td>

                                        <td>
                                            {% for product in products %}
                                                {% if server.service_id == product.id %}
                                                    {{ product.service_name }}
                                                {% endif %}
                                            {% endfor %}
                                        </td>
                                        <td>
                                            {% for product in products %}
                                                {% if server.server_purpose == product.id %}
                                                    {{ product.service_name }}
                                                {% endif %}
                                            {% endfor %}
                                        </td>

                                        <td> {{ server.hostname }} </td>
                                        <td> {{ server.inner_ip }} </td>
                                        <td> {{ server.status }} </td>
                                        <td> {{ server.server_cpu}} </td>
                                        <td> {{ server.server_disk }} G </td>
                                        <td> {{ server.server_mem }} </td>
                                        <td> {{ server.check_update_time|date:"Y-m-d H:i:s"  }} </td>
                                        <td>
                                            <div class="dropdown">
                                                <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                                    修改
                                                    <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                                                    <li><a href="/resources/server/modify/status/?server_id={{ server.id }}">状态</a></li>
                                                    <li><a href="/resources/server/modify/product/?server_id={{ server.id }}">产品线</a></li>
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                {% endfor %}

                            </tbody>

                        </table>




                    </div>

                </div>
                <!-- /tile body -->



            </section>
            <!-- /tile -->
        </div>
        <!-- /col 12 -->

    </div>
    <!-- /row -->

</div>



{% endblock %}
{% block js %}
<script src="/static/assets/js/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="/static/assets/js/vendor/datatables/ColReorderWithResize.js"></script>
<script src="/static/assets/js/vendor/datatables/colvis/dataTables.colVis.min.js"></script>
<script src="/static/assets/js/vendor/datatables/tabletools/ZeroClipboard.js"></script>
<script src="/static/assets/js/vendor/datatables/tabletools/dataTables.tableTools.min.js"></script>
<script src="/static/assets/js/vendor/datatables/dataTables.bootstrap.js"></script>
<script>


    $(function(){
        // Add custom class to pagination div
        $.fn.dataTableExt.oStdClasses.sPaging = 'dataTables_paginate paging_bootstrap paging_custom';

        /* Build the DataTable with third column using our custom sort functions */
        var oTable01 = $('#basicDataTable').dataTable({
        "sDom":
          "R<'row'<'col-md-6'l><'col-md-6'f>r>"+
          "t"+
          "<'row'<'col-md-4 sm-center'i><'col-md-4'><'col-md-4 text-right sm-center'p>>",
        "oLanguage": {
          "sSearch": ""
        },
        "aaSorting": [ [0,'asc'] ],
        "fnInitComplete": function(oSettings, json) {
          $('.dataTables_filter input').attr("placeholder", "Search");
        }
        });

        //initialize chosen
        $('.dataTables_length select').chosen({disable_search_threshold: 10});


    })
</script>

{% endblock %}
